<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
	<title>配送关系查看</title>
	<%@ include file="/WEB-INF/component/commonCSS.jsp"%>
	 <!--[if lt IE 9]>
        <script src="lib/js/html5shiv.min.js"></script>
        <script src="lib/js/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue-light sidebar-mini fixed skin-blue-light-frame">
    <section class="content-header">
        <h1>配送关系查询</h1>
        <ol class="breadcrumb">
            <li><a href="${ctx}/home.jsp"><i class="fa fa-home"></i>首页</a></li>
            <li class="active"><a href="#">交易</a></li>
            <li class="active"><a href="#">配送关系</a></li>
            <li class="active"><a href="#">配送关系查询</a></li>
        </ol>
    </section>
    
    <section class="content">
        <div class=" box box-success">
            <div class="box-body">
                <div class="input">
            	<div class="textalign1">通用名：</div>
                <div class="boxinput">
                    <input class="textinput" type="text" id="drugName" id="drugName" placeholder="通用名" />
                </div>
            	<div class="textalign1">生产企业：</div>
                <div class="boxinput">
                     <input class="textinput"  id="compName" name="compName" type="text" placeholder="生产企业" />
                </div>
				
				<div class="textalign1">配送区域：</div>
            	<div class="boxinput">
            		<table style="width:100%;">
            			<tr>
            				<td style="width:33%;">
            					<select class="textinput"  disabled="disabled" id="area1" name="area1">
	                        		<option value="${area.areaId }">${area.areaName }</option>
	                        	</select>
            				</td>
            				<td style="width:33%;">
            					<select class="textinput"   id="area2" name="area2"></select>
            				</td>
            				<td style="width:33%;">
            					<select class="textinput"   id="area3" name="area3"></select>
            				</td>
            			</tr>
                     </table>
                  </div>
				  
				  <div class="textalign1">
                  		<button type="button"  onclick="gridSerch()"  class="btn btn-success btn-sm" id="selectc">查&nbsp;询</button>
                  </div>
            </div>
            </div>
        </div>
         
        <table class="jqgrid" id="gridlist"></table>
        <div id="prowed2"></div>
            
            <div class=" box box-warning bottongroup" id="bottongroup">
			<!--<label onclick="removeDel();" class="btn btn-primary btn-sm">解 除</label>-->
		</div>
</section>
<%@ include file="/WEB-INF/component/commonJS.jsp"%>
<script type="text/javascript">

	//绑定回车
	$('#goodsCode,#drugCode,#drugName,#compName,#area1,#area2,#area3').bind('keydown', function(event) {
	    if (event.keyCode == "13") {        //13 位电脑上回车键的位置代码
	        $('#selectc').click();
	    }
	}); 
	
	$("#drugName").focus();//加载页面光标在第一个查询框上

function removeDel(){
    var rowIds = $("#gridlist").jqGrid("getGridParam", "selarrrow") || [];
	if (rowIds.length <= 0) {
		$.HN.message.alert("请选择要解除的配送关系！", "消息", "error");
		return;
	}
	$.HN.message.confirm('确定解除所选配送关系吗？', '', '').on(function (e) {
	   			if (e) {
	var param = "";
	for (var i=0; i<rowIds.length; i++) {
		rowId = rowIds[i];
		param += rowId+",";
	}
	param = param.substring(0,param.length-1);
	$.post("${pageContext.request.contextPath}/baseGoods/removeDel.html", {
		"param" : param , "status" :"${status}"
		}, function(result) {
			if (result.success) {
				$.HN.message.alert("解除配送关系成功！", "消息", "success");
				gridSerch();
			} else {
				$.HN.message.alert("操作失败！", "消息", "error");
			}
		}, "json")
		}})
}

$(function () {
	$("#area2").HNSelect({
    	parent_selector: "#area1",  url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID",defaultText: "<option value=''>请选择</option>",
        func: function () {
            $("#area3").HNSelect({
                parent_selector: "#area2", url: "${pageContext.request.contextPath}/selectController/getArea.html", dataid: "ID", defaultText: "<option value=''>请选择</option>",
                		
            });
        }
    });
jQuery("#gridlist").jqGrid({
	url: "${ctx}/baseDel/getBaseDelRelationList.html?status=1",
    mtype: "POST",
	datatype: "json",
	autowidth: true,
	//multiselect:true,
//	height: 255,
	//shrinkToFit:true,
   	colNames:['id','配送区域','中标价','中标后零售价','通用名','剂型','规格','转换系数','单位','材质','商品编码','生产企业','状态'],
   	colModel:[
		{name:'delRelId',index:'delRelId',key:true,hidden:true, width:100, sorttype:"date"},
		{name:'areaName',index:'areaName',align:"center", width:140,  sortable:false},
		{name:'proPriceLimit',index:'proPriceLimit', width:80,align:"right",  sortable:false,
            formatter:function(cellvalue, options,row) {
                var f_x = Math.round(cellvalue * 100) / 100;
	                        var s_x = f_x.toString();
	                        var pos_decimal = s_x.indexOf('.');
	                        
	                        if (pos_decimal < 0) {
	                            pos_decimal = s_x.length;
	                            s_x += '.';
	                        }
	                        
	                        while (s_x.length <= pos_decimal + 2) {
	                            s_x += '0';
	                        }
	                        return s_x;
            }
        },
		{name:'retailPriceLimit',index:'retailPriceLimit', width:80,align:"right",  sortable:false,
            formatter:function(cellvalue, options,row) {
                var f_x = Math.round(cellvalue * 100) / 100;
	                        var s_x = f_x.toString();
	                        var pos_decimal = s_x.indexOf('.');
	                        
	                        if (pos_decimal < 0) {
	                            pos_decimal = s_x.length;
	                            s_x += '.';
	                        }
	                        
	                        while (s_x.length <= pos_decimal + 2) {
	                            s_x += '0';
	                        }
	                        return s_x;
            }
        },
   		{name:'drugName',index:'drugName', width:140, sortable:false},
   		{name:'formName',index:'formName', width:80, align:"center", sortable:false},
   		{name:'specName',index:'specName', width:80, align:"left", sortable:false},
   		{name:'factor',index:'factor', width:80, align:"center", sortable:false},
   		{name:'unit',index:'unit', width:40, align:"center", sortable:false},
   		{name:'materialName',index:'materialName', width:80, align:"left", sortable:false,hidden:true},
   		{name:'goodsCode',align:"center", width:100,sortable:false,hidden:true},
   		{name:'compName',index:'compName', width:180,  sortable:false},
   		
   		{name:'statusText',index:'statusText', width:80,align:"center",  sortable:false,hidden:true}
   		
   	],
	 rowNum: 20,
     rowList: [10, 20, 50,100],
     rownumbers: true,
     pager: "#prowed2",
     viewrecords: true,
     caption: "商品配送关系列表",
     jsonReader: {
         repeatitems: false,
         id: "ids"
     },
     gridComplete:function(){
         //序号列宽度自适应（参数为jqgridID）
         autoRNWidth("gridlist");
         //数据只有一条时默认选中（参数为jqgridID）
         selectByOneData("gridlist");
     }
});
	jQuery("#gridlist").jqGrid('navGrid',"prowed2",{edit:false,add:false,del:false});
	$(window).trigger("resize");
	$("#gridlist").jqGrid("setGridHeight", create());
});


function gridSerch() {
	var goodsCode = $.trim($("#goodsCode").val());
	var drugCode = $.trim($("#drugCode").val());
	var drugName = $.trim($("#drugName").val());
	var compName = $.trim($("#compName").val());
	var areaCode = $.trim($("#area3").val());
	var fatherCode = $.trim($("#area2").val());
	$("#gridlist").jqGrid('setGridParam',{  
        datatype:'json',
        postData:{"goodsCode":goodsCode,
        		"drugCode":drugCode,
        		"drugName":drugName,
        		"compName":compName,
        		"areaCode":areaCode,
        		"fatherCode":fatherCode}
    }).trigger("reloadGrid"); //重新载入  
}

	
</script>
</body>
</html>